From: Alexander Larsson Date: Fri, 9 Oct 2020 08:15:42 +0000 (+0200) Subject: deltas: Take a shared repo lock while reindexing deltas X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~6^2~14^2~5 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=0984ff8471cb758f66e8958813670c8ee99e7358;p=ostree.git deltas: Take a shared repo lock while reindexing deltas This ensures we're not racing with a prune operation that can be removing the delta indexes we're relying on. --- diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c index 670a10a5..5370d152 100644 --- a/src/libostree/ostree-repo-static-delta-core.c +++ b/src/libostree/ostree-repo-static-delta-core.c @@ -1265,6 +1265,12 @@ ostree_repo_static_delta_reindex (OstreeRepo *repo, g_autoptr(GPtrArray) all_deltas = NULL; g_autoptr(GHashTable) deltas_to_commit_ht = NULL; /* map: to checksum -> ptrarray of from checksums (or NULL) */ + /* Protect against parallel prune operation */ + g_autoptr(OstreeRepoAutoLock) lock = + _ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_SHARED, cancellable, error); + if (!lock) + return FALSE; + deltas_to_commit_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)null_or_ptr_array_unref); if (opt_to_commit == NULL)